var objWebSocket = {
    socket: null,
    server_is_full: false,
    
    init:
    function(_this, player_name)
    {
        try
        {
            _this.socket = new WebSocket(globals.host);

            _this.socket.onopen = function()
            {
                $('#content').css('display', 'block');

                _this.socket.send(objCommands.LOGIN + '0000' + player_name);
                objGame.startGame(objGame, true);
                
                startGuiders();
            }

            _this.socket.onmessage = function(msg)
            {
                objCommandee.process(objCommandee, msg.data, _this.socket);
            }

            _this.socket.onclose = function()
            {
                if (_this.server_is_full === false)
                apprise('Server is closed!', {'animate':true});
            }
        }
        catch (exception)
        {
            apprise(exception.toString(), {'animate':true});
        }
    }
};
